package com.acumenvn.pent.Objects;
import javax.security.auth.login.Configuration;

import sun.security.krb5.Config;

import com.acumenvn.pent.Objects.CRect;
import com.acumenvn.pent.Utils.GameInformation;

public class CObject {
	// Public Variables
	public float m_fX;
	public float m_fY;
	public int m_iWidth; 
	public int m_iHeight;
	public char m_style;
	public CRect m_workingArea;
	public float m_vX;
	public float m_vY;
	public float m_rotate;
	public Boolean m_canCollide;
	public Boolean m_canBeDestroyed;
	public int m_spriteIndex;
	public Boolean m_checkedItem;
	public int m_scale;
	public int m_health;
	public CRect m_rect;
	
	// Constructor
	public CObject() {
		// TODO Auto-generated constructor stub
	}
	
	public CObject(float fX, float fY, char style) {
		int sizeTile = GameInformation.getInstance().getSizeTile();
		m_rotate = 0;
		m_scale = 1;
		m_vX = 0;
		m_vY = 0;
		m_workingArea = new CRect(fX, fY, GameInformation.getInstance().getSizeTile(), GameInformation.getInstance().getSizeTile());
		m_canCollide = false;
		m_canBeDestroyed = false;
		m_checkedItem = false;
		m_spriteIndex = 0;
		
		if(style == GameInformation.getInstance().getUnit_Cloud()) {
			// CLOUD
			m_canCollide = true;
			m_rect = new  CRect(fX, fY, 60, 37);
			m_workingArea = new CRect(fX - sizeTile, fY - sizeTile, sizeTile*2, sizeTile*2);
			m_vX = 1;
		} else {
			if(style == GameInformation.getInstance().getUnit_Static()) {
				// STATIC
				m_canCollide = true;
				m_rect = new CRect(fX, fY, sizeTile*2, sizeTile *2);
				m_workingArea = new CRect(fX, fY, sizeTile*2, sizeTile*2);
			} else if(style == GameInformation.getInstance().getUnit_Grass1()) {
				// GRASS 1
				m_rect = new CRect(fX, fY, sizeTile*14, sizeTile*5);
				m_workingArea = new CRect(fX, fY, sizeTile*14, sizeTile*5);
			} else if(style == GameInformation.getInstance().getUnit_Ground1()) {
				// GROUND 1
				m_canCollide = true;
				m_rect = new CRect(fX, fY, sizeTile*11, sizeTile);
				m_workingArea = new CRect(fX, fY, sizeTile*11, sizeTile);
			} else if(style == GameInformation.getInstance().getUnit_Background1()) {
				// BACKGROUND 1
				m_rect = new CRect(fX, fY, sizeTile*20, sizeTile*10);
				m_workingArea = new CRect(fX, fY, sizeTile*500, sizeTile*100);
			} else if(style == GameInformation.getInstance().getUnit_Background2()) {
				// BACKGROUND 2
				m_rect = new CRect(fX, fY, sizeTile*20, sizeTile*10);
				m_workingArea = new CRect(fX, fY, sizeTile*500, sizeTile*100);
			} else if(style == GameInformation.getInstance().getUnit_Rock1()) {
				// ROCK 1
				m_canCollide = true;
				m_canBeDestroyed = false;
				m_checkedItem = false;
				m_rect = new CRect(fX, fY, sizeTile*1, sizeTile);
				m_workingArea = new CRect(fX, fY, sizeTile, sizeTile);
			} else if(style == GameInformation.getInstance().getUnit_Save()) {
				// SAVE
				m_canCollide = false;
				m_checkedItem = true;
				m_rect = new CRect(fX, fY, 52, 81);
				m_workingArea = new CRect(fX, fY, sizeTile, sizeTile*2);
			} else if(style == GameInformation.getInstance().getUnit_Begin()) {
				// BEGIN
				m_canCollide = true;
			} else if(style == GameInformation.getInstance().getUnit_End()) {
				// END
				m_canCollide = false;
				m_checkedItem = true;
				m_rect = new CRect(fX, fY,130, 112);
				m_workingArea = new CRect(fX, fY, sizeTile, sizeTile);
			} else if(style == GameInformation.getInstance().getUnit_Monster1()) {
				// Monster 1
				m_canCollide = false;
				m_checkedItem = true;
				m_canBeDestroyed = true;
				m_rect = new CRect(fX, fY, 40, 40);
				m_workingArea = new CRect(fX - sizeTile*10, fY - sizeTile*10, sizeTile*20, sizeTile*20);
				m_vX = 0;
				m_vY = 0;
			} else if(style == GameInformation.getInstance().getUnit_Monster2()) {
				// Monster 2
				m_canCollide = false;
				m_checkedItem = true;
				m_canBeDestroyed = true;
				m_rect = new CRect(fX, fY, 40, 40);
				m_workingArea = new CRect(fX - sizeTile*12, fY - sizeTile*10, sizeTile*20, sizeTile*20);
				m_vX = 2;
				m_vY = 0;
			} else if(style == GameInformation.getInstance().getUnit_Monster3()) {
				// Monster 3
				m_canCollide = false;
				m_checkedItem = true;
				m_canBeDestroyed = true;
				m_rect = new CRect(fX, fY, 40, 40);
				m_workingArea = new CRect(fX-sizeTile*4, fY-sizeTile*4, sizeTile*8, sizeTile*8);
				m_vX = 2;
				m_vY = 0;
			} else if(style == GameInformation.getInstance().getUnit_Fire1()) {
				// Fire
				m_canCollide = true;
				m_checkedItem = true;
				m_canBeDestroyed = false;
				m_rect = new CRect(fX,fY, sizeTile, sizeTile*2);
				m_workingArea = new CRect(fX,fY,sizeTile,sizeTile*2);
			} else if(style == GameInformation.getInstance().getUnit_Trap()) {
				// Trap
				m_canCollide = true;
				m_checkedItem = true;
				m_canBeDestroyed = false;
				m_rect = new CRect(fX,fY, sizeTile, sizeTile*2);
				m_workingArea = new CRect(fX,fY,sizeTile,sizeTile*2);
			} else if(style == GameInformation.getInstance().getUnit_Grass1M2()) {
				// Grass 1 M2
				m_rect = new CRect(fX, fY, sizeTile*14, sizeTile*5);
				m_workingArea = new CRect(fX, fY, sizeTile*14, sizeTile*5);
			} else if(style == GameInformation.getInstance().getUnit_Grass2M2()) {
				// Grass 2 M2
				m_rect = new CRect(fX, fY, sizeTile*14, sizeTile*5);
				m_workingArea = new CRect(fX, fY, sizeTile*14, sizeTile*5);
			} else if(style == GameInformation.getInstance().getUnit_RockM2()) {
				// Rock M2
				m_canCollide = true;
				m_canBeDestroyed = false;
				m_checkedItem = false;
				m_rect = new CRect(fX, fY, sizeTile, sizeTile);
				m_workingArea = new CRect(fX, fY, sizeTile, sizeTile);
			} else if(style == GameInformation.getInstance().getUnit_Ground1M2()) {
				// Ground 1 M2
				m_canCollide = true;
				m_rect = new CRect(fX, fY, sizeTile*11, sizeTile);
				m_workingArea = new CRect(fX, fY, sizeTile*11, sizeTile);
			}
		}
		
		m_health = 1;
		m_style = style;
		m_fX = fX;
		m_fY = fY;
		m_iHeight = (int)(m_rect.getBottom()  - m_rect.getTop());
		m_iWidth = (int)(m_rect.getRight() - m_rect.getLeft());
	}
	
	public void free() {
		m_style = (Character)null;
	}
}

